/* Class39_Sub7 - Decompiled by JODE
 * Visit http://jode.sourceforge.net/
 */
import java.io.DataInputStream;
import java.net.URL;

public class Class39_Sub7 extends Node {
	public static int[] anIntArray1371 = new int[1000];
	public int anInt1372;
	public static volatile boolean aBoolean1373 = false;
	public static long[] aLongArray1374 = new long[32];
	public static int[] anIntArray1375;
	public int[] anIntArray1376;
	public Resource[] aClass56Array1377;
	public int[] anIntArray1378;
	public int[] anIntArray1379;
	public static int anInt1380 = 0;
	public byte[][][] aByteArrayArrayArray1381;
	public int anInt1382;
	public Resource[] aClass56Array1383;
	public static JString aClass3_1384;
	public static long[] aLongArray1385;
	public static int anInt1386;
	public static int anInt1387;
	public static JString aClass3_1388;

	public static void method845(int i, byte[] is) {
		Stream class39_sub6 = new Stream(is);
		class39_sub6.currentOffset = is.length - 2;
		RSSocket.anInt302 = class39_sub6.readShort(-80);
		Class39_Sub5_Sub9.anIntArray1799 = new int[RSSocket.anInt302];
		CollisionMap.aByteArrayArray517 = new byte[RSSocket.anInt302][];
		Class39_Sub5.anIntArray1352 = new int[RSSocket.anInt302];
		Class39_Sub14.anIntArray1512 = new int[RSSocket.anInt302];
		Class46_Sub1.anIntArray1548 = new int[RSSocket.anInt302];
		class39_sub6.currentOffset = is.length - 7 - RSSocket.anInt302 * 8;
		Class13.anInt203 = class39_sub6.readShort(-113);
		Class39_Sub5_Sub12.anInt1854 = class39_sub6.readShort(118);
		int i_0_ = (class39_sub6.readByte((byte) -8) & 0xff) + 1;
		for (int i_1_ = 0; RSSocket.anInt302 > i_1_; i_1_++)
			Class46_Sub1.anIntArray1548[i_1_] = class39_sub6.readShort(-87);
		for (int i_2_ = 0; RSSocket.anInt302 > i_2_; i_2_++)
			Class39_Sub5.anIntArray1352[i_2_] = class39_sub6.readShort(-115);
		for (int i_3_ = 0; RSSocket.anInt302 > i_3_; i_3_++)
			Class39_Sub5_Sub9.anIntArray1799[i_3_] = class39_sub6.readShort(-103);
		for (int i_4_ = 0; i_4_ < RSSocket.anInt302; i_4_++)
			Class39_Sub14.anIntArray1512[i_4_] = class39_sub6.readShort(-8);
		class39_sub6.currentOffset = 3 - i_0_ * 3 + (is.length - 7 - RSSocket.anInt302 * 8);
		Class39_Sub11.anIntArray1460 = new int[i_0_];
		for (int i_5_ = 1; i_0_ > i_5_; i_5_++) {
			Class39_Sub11.anIntArray1460[i_5_] = class39_sub6.read3Bytes((byte) -62);
			if (Class39_Sub11.anIntArray1460[i_5_] == 0)
				Class39_Sub11.anIntArray1460[i_5_] = 1;
		}
		class39_sub6.currentOffset = 0;
		for (int i_6_ = 0; RSSocket.anInt302 > i_6_; i_6_++) {
			int i_7_ = Class39_Sub14.anIntArray1512[i_6_];
			int i_8_ = Class39_Sub5_Sub9.anIntArray1799[i_6_];
			int i_9_ = i_7_ * i_8_;
			byte[] is_10_ = new byte[i_9_];
			CollisionMap.aByteArrayArray517[i_6_] = is_10_;
			int i_11_ = class39_sub6.readByte((byte) -8);
			if (i_11_ == 0) {
				for (int i_12_ = 0; i_12_ < i_9_; i_12_++)
					is_10_[i_12_] = class39_sub6.readSignedByte(67);
			} else if (i_11_ == 1) {
				for (int i_13_ = 0; i_13_ < i_8_; i_13_++) {
					for (int i_14_ = 0; i_14_ < i_7_; i_14_++)
						is_10_[i_8_ * i_14_ + i_13_] = class39_sub6.readSignedByte(-94);
				}
			}
		}
	}

	public static void method846(GameCharacter class39_sub5_sub4_sub4, int i) {
		class39_sub5_sub4_sub4.aBoolean2298 = false;
		if (i != 1000000)
			method849(null, 39, null);
		if (class39_sub5_sub4_sub4.anInt2303 != -1) {
			Class39_Sub5_Sub11 class39_sub5_sub11 = Class62_Sub1.method1064(class39_sub5_sub4_sub4.anInt2303, (byte) 54);
			if (class39_sub5_sub11 != null && class39_sub5_sub11.anIntArray1833 != null) {
				class39_sub5_sub4_sub4.anInt2283++;
				if ((class39_sub5_sub4_sub4.anInt2306 < class39_sub5_sub11.anIntArray1833.length) && ((class39_sub5_sub11.anIntArray1831[class39_sub5_sub4_sub4.anInt2306]) < class39_sub5_sub4_sub4.anInt2283)) {
					class39_sub5_sub4_sub4.anInt2306++;
					class39_sub5_sub4_sub4.anInt2283 = 1;
				}
				if (class39_sub5_sub11.anIntArray1833.length <= class39_sub5_sub4_sub4.anInt2306) {
					class39_sub5_sub4_sub4.anInt2306 = 0;
					class39_sub5_sub4_sub4.anInt2283 = 0;
				}
			} else
				class39_sub5_sub4_sub4.anInt2303 = -1;
		}
		if (class39_sub5_sub4_sub4.anInt2270 != -1 && Class2.anInt48 >= class39_sub5_sub4_sub4.anInt2272) {
			if (class39_sub5_sub4_sub4.anInt2276 < 0)
				class39_sub5_sub4_sub4.anInt2276 = 0;
			int i_15_ = (Class40.method881(i ^ 0xf4240, class39_sub5_sub4_sub4.anInt2270).anInt2126);
			if (i_15_ != -1) {
				Class39_Sub5_Sub11 class39_sub5_sub11 = Class62_Sub1.method1064(i_15_, (byte) 54);
				if (class39_sub5_sub11 != null && class39_sub5_sub11.anIntArray1833 != null) {
					class39_sub5_sub4_sub4.anInt2304++;
					if ((class39_sub5_sub4_sub4.anInt2276 < class39_sub5_sub11.anIntArray1833.length) && (class39_sub5_sub4_sub4.anInt2304 > (class39_sub5_sub11.anIntArray1831[class39_sub5_sub4_sub4.anInt2276]))) {
						class39_sub5_sub4_sub4.anInt2276++;
						class39_sub5_sub4_sub4.anInt2304 = 1;
					}
					if ((class39_sub5_sub11.anIntArray1833.length <= class39_sub5_sub4_sub4.anInt2276) && (class39_sub5_sub4_sub4.anInt2276 < 0 || (class39_sub5_sub4_sub4.anInt2276 >= class39_sub5_sub11.anIntArray1833.length)))
						class39_sub5_sub4_sub4.anInt2270 = -1;
				} else
					class39_sub5_sub4_sub4.anInt2270 = -1;
			} else
				class39_sub5_sub4_sub4.anInt2270 = -1;
		}
		if (class39_sub5_sub4_sub4.anInt2268 != -1 && class39_sub5_sub4_sub4.anInt2305 <= 1) {
			Class39_Sub5_Sub11 class39_sub5_sub11 = Class62_Sub1.method1064(class39_sub5_sub4_sub4.anInt2268, (byte) 54);
			if (class39_sub5_sub11.anInt1840 == 1 && class39_sub5_sub4_sub4.anInt2254 > 0 && Class2.anInt48 >= class39_sub5_sub4_sub4.anInt2256 && Class2.anInt48 > class39_sub5_sub4_sub4.anInt2261) {
				class39_sub5_sub4_sub4.anInt2305 = 1;
				return;
			}
		}
		if (class39_sub5_sub4_sub4.anInt2268 != -1 && class39_sub5_sub4_sub4.anInt2305 == 0) {
			Class39_Sub5_Sub11 class39_sub5_sub11 = Class62_Sub1.method1064(class39_sub5_sub4_sub4.anInt2268, (byte) 54);
			if (class39_sub5_sub11 != null && class39_sub5_sub11.anIntArray1833 != null) {
				class39_sub5_sub4_sub4.anInt2311++;
				if ((class39_sub5_sub11.anIntArray1833.length > class39_sub5_sub4_sub4.anInt2265) && ((class39_sub5_sub11.anIntArray1831[class39_sub5_sub4_sub4.anInt2265]) < class39_sub5_sub4_sub4.anInt2311)) {
					class39_sub5_sub4_sub4.anInt2265++;
					class39_sub5_sub4_sub4.anInt2311 = 1;
				}
				if (class39_sub5_sub4_sub4.anInt2265 >= class39_sub5_sub11.anIntArray1833.length) {
					class39_sub5_sub4_sub4.anInt2291++;
					if (class39_sub5_sub4_sub4.anInt2291 >= class39_sub5_sub11.anInt1829)
						class39_sub5_sub4_sub4.anInt2268 = -1;
					class39_sub5_sub4_sub4.anInt2265 -= class39_sub5_sub11.anInt1839;
					if (class39_sub5_sub4_sub4.anInt2265 < 0 || (class39_sub5_sub11.anIntArray1833.length <= class39_sub5_sub4_sub4.anInt2265))
						class39_sub5_sub4_sub4.anInt2268 = -1;
				}
				class39_sub5_sub4_sub4.aBoolean2298 = class39_sub5_sub11.aBoolean1838;
			} else
				class39_sub5_sub4_sub4.anInt2268 = -1;
		}
		if (class39_sub5_sub4_sub4.anInt2305 > 0)
			class39_sub5_sub4_sub4.anInt2305--;
	}

	public static void method847(byte i) {
		aLongArray1374 = null;
		anIntArray1375 = null;
		aLongArray1385 = null;
		aClass3_1384 = null;
		aClass3_1388 = null;
		anIntArray1371 = null;
	}

	public static int method848(int i, int i_16_, byte i_17_, int i_18_) {
		i_16_ &= 0x3;
		if (i_16_ == 0)
			return i_18_;
		if (i_16_ == 1)
			return -i + 7;
		if (i_16_ == 2)
			return -i_18_ + 7;
		return i;
	}

	public static void method849(Throwable throwable, int i, String string) {
		do {
			try {
				String string_19_ = "";
				if (throwable != null)
					string_19_ = Class40.method884(throwable, (byte) -27);
				if (string != null) {
					if (throwable != null)
						string_19_ += " | ";
					string_19_ += (String) string;
				}
				System.out.println("Error: " + string_19_);
				string_19_ = string_19_.replace(':', '.');
				string_19_ = string_19_.replace('@', '_');
				string_19_ = string_19_.replace('&', '_');
				string_19_ = string_19_.replace('#', '_');
				Resource class56 = (Class7.aClass21_108.method249((byte) -71, new URL(Class7.aClass21_108.anApplet416.getCodeBase(), ("clienterror.ws?c=" + OnDemandFetcher.anInt1198 + "&u=" + client.aLong1278 + "&v1=" + Signlink.aString401 + "&v2=" + Signlink.aString407 + "&e=" + string_19_))));
				while (class56.state == 0)
					Class45.method917(3, 1L);
				if (class56.state != 1)
					break;
				DataInputStream datainputstream = (DataInputStream) class56.resource;
				datainputstream.read();
				datainputstream.close();
			} catch (Exception exception) {
				break;
			}
			break;
		} while (false);
	}

	public static CacheArchive method850(int i, boolean bool, boolean bool_20_, boolean bool_21_, byte i_22_) {
		CacheIO class6 = null;
		if (Class43.cacheDataFile != null)
			class6 = new CacheIO(i, Class43.cacheDataFile, Class39_Sub5_Sub4_Sub4_Sub1.cacheIndexFiles[i], 1000000);
		return new CacheArchive(class6, Class14.aClass6_229, i, bool_21_, bool, bool_20_);
	}

	public static int method851(int i, int i_23_, int i_24_, int i_25_, int i_26_) {
		int i_27_ = (65536 - Rasterizer.anIntArray2456[i * 1024 / i_25_] >> 1);
		return ((-i_27_ + 65536) * i_24_ >> 16) + (i_27_ * i_23_ >> 16);
	}

	public static Class39_Sub5_Sub10_Sub3[] method852(JString class3, Class9 class9, JString class3_28_, int i) {
		int i_29_ = class9.method163(class3, (byte) 30);
		int i_30_ = class9.method143(100, i_29_, class3_28_);
		return Class23.method273(i_30_, (byte) -49, i_29_, class9);
	}

	static {
		anIntArray1375 = new int[256];
		aClass3_1384 = Class39_Sub5_Sub9.createJString(115, "overlay_multiway");
		for (int i = 0; i < 256; i++) {
			int i_31_ = i;
			for (int i_32_ = 0; i_32_ < 8; i_32_++) {
				if ((i_31_ & 0x1) == 1)
					i_31_ = ~0x12477cdf ^ i_31_ >>> 1;
				else
					i_31_ >>>= 1;
			}
			anIntArray1375[i] = i_31_;
		}
		anInt1386 = 0;
		aLongArray1385 = new long[100];
		anInt1387 = 10;
		aClass3_1388 = Class39_Sub5_Sub9.createJString(105, "mapfunction");
	}
}
